package com.zp.responsibility;/**
 * @description
 * @author zp
 * @created 2021/9/3 22:20
 */

/**
 * @author zp
 * @description
 * @created 2021/9/3 22:20
 */
public abstract class AbstractLogger {
    public static int INFO = 1;
    public static int WARNING = 2;
    public static int ERROR = 3;
    protected int level;
    private AbstractLogger nextAbstractLogger;
    public void setNextLogger(AbstractLogger nextLogger){
        this.nextAbstractLogger = nextLogger;
    }

    public void logMessage(int level,String message){
        if(this.level<=level){
            write(message);
        }
        if(nextAbstractLogger!=null){
            nextAbstractLogger.logMessage(level,message);
        }
    }

    protected abstract void write(String message);
}
